www.gusucode.com > VC++网络版的打字软件源程序-源码程序 > VC++网络版的打字软件源程序-源码程序\code\TypeSrv V2.0\AddScoreDlg.cpp

    // AddScoreDlg.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "typesrv.h"
#include "AddScoreDlg.h"
#include "QuestionSet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAddScoreDlg dialog


CAddScoreDlg::CAddScoreDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAddScoreDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAddScoreDlg)
	m_strID = _T("");
	m_strName = _T("");
	m_nRate = 0;
	m_nSpeed = 0;
	m_strTestDate = _T("");
	//}}AFX_DATA_INIT
	m_nQuestionID=-1;
	m_strWndText="添加成绩";
}


void CAddScoreDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAddScoreDlg)
	DDX_Control(pDX, IDC_QUESTION, m_ctrlQuestion);
	DDX_Text(pDX, IDC_ID, m_strID);
	DDV_MaxChars(pDX, m_strID, 6);
	DDX_Text(pDX, IDC_NAME, m_strName);
	DDV_MaxChars(pDX, m_strName, 12);
	DDX_Text(pDX, IDC_RATE, m_nRate);
	DDX_Text(pDX, IDC_SPEED, m_nSpeed);
	DDX_Text(pDX, IDC_TESTDATE, m_strTestDate);
	DDV_MaxChars(pDX, m_strTestDate, 14);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAddScoreDlg, CDialog)
	//{{AFX_MSG_MAP(CAddScoreDlg)
	ON_CBN_SELCHANGE(IDC_QUESTION, OnSelchangeQuestion)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddScoreDlg message handlers

BOOL CAddScoreDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetWindowText(m_strWndText);

	CQuestionSet* pSet=new CQuestionSet;
	int nIndex=0;
	
	pSet->Open();
	if(!pSet->IsBOF())
		pSet->MoveFirst();

	while(!pSet->IsEOF())
	{
		m_ctrlQuestion.AddString(pSet->m_Info);
		nIndex=m_ctrlQuestion.GetCount()-1;
		m_ctrlQuestion.SetItemData(nIndex,(DWORD)pSet->m_ID);
		pSet->MoveNext();
	}

	pSet->Close();
	delete pSet;

	if(m_nQuestionID!=-1)
	{
		CQuestionSet* pSet=new CQuestionSet;
		CString strSQL;
		strSQL.Format("Select* From Question Where ID=%ld",m_nQuestionID);
		pSet->Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
		if(pSet->GetRecordCount()==1)
		{
			m_ctrlQuestion.SetWindowText(pSet->m_Info);
		}
		pSet->Close();
		delete pSet;
	}
	

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAddScoreDlg::OnSelchangeQuestion() 
{
	// TODO: Add your control notification handler code here
	int nIndex=m_ctrlQuestion.GetCurSel();
	m_nQuestionID=(long)m_ctrlQuestion.GetItemData(nIndex);
}